#include "wap_main.h"
#include "wa_wm.h"
#include "wa_win.h"
#include "wa_img.h"
#include "wa_screen.h"
#include "wap.h"

static void wap_main_create(void);
static void wap_main_del(void);
static void wap_main_callback(wa_sign* sign);

wa_screen_obj wap_main_screen = 
{
	.id = WAP_WIN_MAIN_ID,
	.create = wap_main_create,
	.del = wap_main_del,
};

wa_obj* wap_main_win;
wa_obj* wap_main_img; 

extern wa_bitmap img_logo;

void wap_main_init(void)
{
}

static void wap_main_create(void)
{
	wap_main_win = wa_win_create(NULL);
	wa_win_set_pos(wap_main_win, 0, 0);
	wa_win_set_size(wap_main_win, WA_LCD_W, WA_LCD_H);
	wa_win_set_edge_show(wap_main_win, wa_nok);
	wa_win_set_callback(wap_main_win, wap_main_callback);
	wap_main_screen.win = wap_main_win;
	
	wap_main_img = wa_img_create(NULL);
	wa_win_add_obj(wap_main_win, wap_main_img);
	wa_obj_set_pos(wap_main_img, 0, 0);
	wa_obj_set_size(wap_main_img, WA_LCD_W, WA_LCD_H);
	wa_img_set_bitmap(wap_main_img, &img_logo);
}

static void wap_main_del(void)
{
	wa_obj_del(wap_main_win);
}

static void _wap_main_paint(wa_obj* obj)
{
}

static void wap_main_callback(wa_sign* sign)
{
	int sign_id;
	wa_obj* obj;
	sign_id = sign->sign_id;
	obj = sign->obj_dst;

	switch (sign_id)
	{
		case WA_SIGNAL_PAINT:
		{
			_wap_main_paint(obj);
			break;
		}
		case WA_SIGNAL_NOTIFY_PARENT:
		{	
			break;
		}
		case WA_SIGNAL_USER_KEY_ENTER:
		{	
			wa_screen_switch(WAP_WIN_MENU_ID, WA_SCREEN_SWITCH_TYPE_TOP_MOVE_ENTER, 500, wa_nok, wa_nok);
			break;
		}
		default:
		{
			break;
		}
	}
}
